module.exports = {
	data() {
        return {
            mixin: "全局混入"
        }
	},

    methods: {
        // 获取设备信息 
        mixinGetSysInfo(){
            const sysInfo = uni.$u.sys();
            // #ifdef MP-WEIXIN
            const capsule = wx.getMenuButtonBoundingClientRect();
            capsule.navBarH = capsule.height + 2*(capsule.top - sysInfo.statusBarHeight);
            capsule.navBarPBGap = capsule.top - sysInfo.statusBarHeight;
            capsule.navBarLRGap = sysInfo.windowWidth - capsule.right;
            sysInfo.capsule = capsule;
            // #endif 
            return sysInfo;
        },

        // 返回上一页面并刷新
		mixinBackPrePage(number){
            const pages = getCurrentPages()
            if( pages.length == 1 ){ 
                uni.navigateBack({ delta: 100 })
            } else {
                let beforePage
                if( number ){
                    beforePage = pages[pages.length - 2] // 上一页面
                }else{
                    beforePage = pages[pages.length - (number+1)] // 指定页面
                }
                // 更新页面数据
                try{
                    beforePage.$vm.refreshData();
                } catch (e) {
                    console.log("refreshData出错");
                }
                // 返回
                if( number ){
                    uni.navigateBack({ delta: 1 })
                } else {
                    uni.navigateBack({ delta: number })
                }
            }
        }
	}
}
